package com.iscas.tech.utils;

import com.iscas.tech.entity.AtMdbusyValue;
import com.iscas.tech.entity.AtNewsattach;
import com.iscas.tech.entity.AtStpic;
import com.iscas.tech.vo.AtNewsattachQueryVo;
import com.iscas.tech.vo.AtStpicQueryVo;
import com.iscas.tech.vo.Tag;

import java.util.ArrayList;
import java.util.List;

public class DataUtil {
    /**
     * 拼接业务模块绑定类
     *
     * @param id          业务ID
     * @param createTitle 创建人ID
     * @param tagList     标签列表
     * @return 业务模块绑定列表
     */
    public static List<AtMdbusyValue> getBusinessList(Integer id, Integer createTitle, List<Tag> tagList) {
        List<AtMdbusyValue> businessList = new ArrayList<>();
        if (tagList != null) {
            for (Tag tag : tagList) {
                AtMdbusyValue business = new AtMdbusyValue();
                business.setBsId(id);
                business.setMdId(tag.getMdId());
                business.setMvId(tag.getMvId());
                business.setMdType(tag.getMdType());
                business.setCreatetitle(createTitle);
                businessList.add(business);
            }
        }
        return businessList;
    }

    /**
     * 拼接科技成果图片类
     *
     * @param stId        科技成果ID
     * @param createTitle 创建人ID
     * @param picList     图片列表
     * @return 科技成果图片列表
     */
    public static List<AtStpic> getStPicList(Integer stId, Integer createTitle, List<AtStpicQueryVo> picList) {
        List<AtStpic> stPicList = new ArrayList<>();
        if (picList != null) {
            for (AtStpicQueryVo pic : picList) {
                AtStpic stPic = new AtStpic();
                stPic.setCreatetitle(createTitle);
                stPic.setPType(pic.getpType());
                stPic.setPUrl(pic.getpUrl());
                stPic.setStId(stId);
                stPicList.add(stPic);
            }
        }
        return stPicList;
    }

    /**
     * 拼接新闻附件类
     *
     * @param newsId      新闻主键ID
     * @param createTitle 记录人
     * @param fileList    附件列表
     * @return 新闻附件列表
     */
    public static List<AtNewsattach> getNewsFileList(Integer newsId, Integer newsType, Integer createTitle, List<AtNewsattachQueryVo> fileList) {
        List<AtNewsattach> newFileList = new ArrayList<>();
        for (AtNewsattachQueryVo file : fileList) {
            AtNewsattach newsFile = new AtNewsattach();
            newsFile.setAtType(newsType);
            newsFile.setAtUrl(file.getAtUrl());
            newsFile.setCreatetitle(createTitle);
            newsFile.setNId(newsId);
            newsFile.setNTitle(file.getnTitle());
            newFileList.add(newsFile);
        }
        return newFileList;
    }
}
